- 时间转字符串
1 | select date_format(now(), '%Y-%m-%d'); |
- 时间转时间戳
1 | select unix_timestamp(now()); |
- 字符串转时间
1 | select str_to_date('2016-01-02', '%Y-%m-%d %H'); |
- 字符串转时间戳
1 | select unix_timestamp('2016-01-02'); |
- 时间戳转日期,默认
1 | select from_unixtime(UNIX_TIMESTAMP()); |
- 时间戳转日期,指定格式
1 | select from_unixtime(UNIX_TIMESTAMP(),'%Y-%m-%d'); |